package com.dengdai.applibrary.sqlite;

import com.dengdai.applibrary.R;
import com.dengdai.applibrary.base.BaseApplication;
import com.j256.ormlite.dao.Dao;

/**
 * @说明 数据库操作基类
 * @作者 LY
 * @时间 15/12/21 09:52
 * @版权 Copyright(c) 2015 LY-版权所有
 */
public class BaseTableHelper<T> {
    public Dao<T, Integer> daoOpe;
    public DatabaseHelper helper;

    /**
     * 初始化对象
     *
     * @param c
     */
    public void initSqlite(Class c) {
        //数据库名称
        String name = BaseApplication.getAppContext().getResources().getString(R.string.dataBaseName);
        //数据库版本
        int version = BaseApplication.getAppContext().getResources().getInteger(R.integer.dataBaseVersion);
        try {
            helper = DatabaseHelper.gainInstance(name, version);
            daoOpe = helper.getDao(c);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
